//package com.feng.study.handler;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.web.HttpRequestMethodNotSupportedException;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestControllerAdvice;
//
//import javax.servlet.http.HttpServletRequest;
//
///**
// * @Author: Zeng ShaoYong
// * @Date: 2022-10-09
// * @Description: 全局异常捕获机制
// */
//@Slf4j
//@RestControllerAdvice
//public class GlobalExceptionHandler {
//
//    @ResponseBody
//    @ExceptionHandler(value = Exception.class)
//    public String allUnknowExceptionHandler(HttpServletRequest request, Exception exception) throws HttpRequestMethodNotSupportedException {
//        String msg = "Exception error";
//        return msg;
//    }
//
//    @ResponseBody
//    @ExceptionHandler(value = {ArithmeticException.class, ArrayIndexOutOfBoundsException.class})
//    public String arrayIndexOutOfBoundsExceptionHandler(HttpServletRequest request, Exception exception) throws HttpRequestMethodNotSupportedException {
//        String msg = "error";
//        if (exception instanceof ArithmeticException) {
//            log.error("错误日志 url: {}, exception: {}", request.getRequestURL(), exception.getMessage());
//            msg = "ava.lang.ArithmeticException,异常发送";
//        }
//        if (exception instanceof ArrayIndexOutOfBoundsException) {
//            log.error("错误日志 url: {}, exception: {}", request.getRequestURL(), exception.getMessage());
//            msg = "ava.lang.ArrayIndexOutOfBoundsException,异常发送";
//        }
//        return msg;
//    }
//}
